from appium import webdriver

def init_driver():

    desired_caps = {}

    # 添加平台类型
    desired_caps["platformName"] = "Android"

    # 添加系统版本
    desired_caps["platformVersion"] = "9"

    # 添加手机名称
    desired_caps["deviceName"] = "554"

    # 程序的包名
    desired_caps["appPackage"] = "com.android.contacts"

    # 程序的界面名
    desired_caps["appActivity"] = ".activities.PeopleActivity"

    # 不重置应用
    desired_caps["noReset"] = True

    # 输入中文
    desired_caps["unicodeKeyboard"] = True
    desired_caps["resetKeyboard"] = True

    driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

    return driver
